﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>">
	<!-- jsp文件头和头部 -->
	<%@ include file="../../system/main/main_top.jsp"%> 
	</head> 
<body>
	<form action="offlinepay/list.do" method="post" name="productInfoForm" id="productInfoForm">
	<div id="centerOfMainFrame" style="margin: 20px;20px;20px;20px; ">
		<!-- 检索  -->
		<input type="hidden" name="organ_id" id="organ_id" value="${pageData.organ_id }"/>
		<div style="float: left; width: 60%;">
			<div> 
				<i class="icon-circle green"></i>请选择营销经理(非必选)：
			 	<select class="chzn-select" name="markting_id" id="markting_id" data-placeholder="请选择营销经理" style="vertical-align:top;width: 36%;">
				<option value="">全部</option>
				<c:forEach items="${marktingList}" var="markting">
					<option value="${markting.m_id }">${markting.mobile }-${markting.username }</option>
				</c:forEach>
			  	</select>
			</div>
			<br/>
			<div>
				<i class="icon-circle green"></i>请输入支付金额：<input type="text" name="pay_amount" id="pay_amount" maxlength="32" title="支付金额 " style="width:70%;"/>
			</div>
			<div>
				<i class="icon-circle green"></i>请输入支付说明：<textarea style="width:70%;height:220px" name="pay_reason" id="pay_reason"></textarea>
			</div>
		</div>
		<div style="float: right;">
			<div class="name">
			    <span class="input-group-btn">
			 		<a class="btn btn-small btn-success" onclick="addOfflinePay();">点击生成支付二维码</a>
			 	</span>
			</div>
			<div style="width:285px;float: left;">
				<div class="widget-box">
					<div class="widget-header widget-header-flat widget-header-small">
						<h5><i class="icon-credit-card"></i> 
							线下支付二维码
						</h5>
						<div class="widget-toolbar no-border">
							
						</div>
					</div>
					
					<div class="widget-body">
					 <div class="widget-main">
						<img id="encoderImgId" src="<%=basePath%>static/img/default.png" width="265px" height="265px;"/>
					 </div><!--/widget-main-->
					</div><!--/widget-body-->
				</div><!--/widget-box-->
			 </div><!--/span-->	
		</div>
	</div>
	<div id="centerOfMainFrame2" class="center" style="display:none"><br/><br/><br/><br/><br/><img src="static/images/jiazai.gif" /><br/><h4 class="lighter block green">提交中...</h4></div>
	<!-- PAGE CONTENT ENDS HERE -->
	</form>
		<!-- 引入 -->
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
		<script type="text/javascript" src="static/js/ace.min.js"></script>
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 单选框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
		<!-- 引入 -->
		
		<script type="text/javascript">
		$(top.hangge());
		
		$(function() {
			//单选框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
			//日期框
			$('.date-picker').datepicker();
		});
		
		//生成二维码
		function addOfflinePay(){
			if($("#pay_amount").val()==""){
				$("#pay_amount").tips({
					side:3,
		            msg:'输入支付金额',
		            bg:'#AE81FF',
		            time:3
		        });
				$("#pay_amount").focus();
				return false;
			}else{
				var pay_amount = $("#pay_amount").val();
				//alert(!isNaN(latitude));
				if(isNaN(pay_amount)){
					$("#pay_amount").tips({
						side:3,
			            msg:'支付金额必须是数值',
			            bg:'#AE81FF',
			            time:3
			        });
					$("#pay_amount").focus();
					return false;
				}
			}
			
			$("#encoderImgId").attr("src", "<%=basePath%>/static/images/jzx.gif");
			$.ajax({
				type: "POST",
				url: '<%=basePath%>/offlinepay/createTwoDimensionCode.do',
		    	data: {organ_id:$("#organ_id").val(),markting_id:$("#markting_id").val(),pay_amount:$("#pay_amount").val(),pay_reason:$("#pay_reason").val(),tm:new Date().getTime()},
				dataType:'json',
				cache: false,
				success: function(data){
					 if("success" == data.result){
						 $("#encoderImgId").tips({
								side:1,
					            msg:'生成成功',
					            bg:'#75C117',
					            time:3
					     });
						 $("#encoderImgId").attr("src", data.encoderImgId);       
					 }else{
						 $("#encoderImgId").tips({
								side:3,
					            msg:'生成失败,后台有误',
					            bg:'#FF5080',
					            time:10
					     });
						 $("#encoderImgId").attr("src", "<%=basePath%>/uploadFiles/twoDimensionCode/default.png");
						 return;
					 }
				}
			});
		}
		</script>
	</body>
</html>

